extends ./layout/home
block title
block content
	script.
		function cutstr(str, len) {
			var temp;
			var icount = 0;
			var patrn = /[^\x00-\xff]/;
			var strre = "";
			for (var i = 0; i < str.length; i++) {
			    if (icount < len - 1) {
				    temp = str.substr(i, 1);
				    if (patrn.exec(temp) == null) {
				    	icount = icount + 1
				    } else {
				    	icount = icount + 2
				    }
				    	strre += temp
				} else {
				    break;
				}
			}
			return strre + "..."
		}
	header.detailTit.container-fluid
		.container.clearfix
			div.logo.col-4
				span 豆瓣 
				span d
				span.oa o
				span.un u
				span b
				span.oa a
				span.un n
				a.btn.btn-default.btn-nav(href="/")
						i.fa.fa-home
						span 主页
				a.btn.btn-default.btn-nav
					i.fa.fa-th-large
					span 导航
					span.fa.fa-caret-down
			div.search.col-5
				form.clearfix
					input.form-control.col-10(type="text",placeholder="Search in for ...")
					button.btn.btn-success.col-2 搜全网
			div.top-nav
				if user
					a#userId(href="/admin/",userId="#{user._id}",userName="#{user.username}") 欢迎您 #{user.username}
				else
					a#userId(href="/admin/login",userId=null,userName=null) 请登录!
				a(href="/admin/register") 注册
	.flash.container-fluid
		.container.clearfix.flashCont
			.col-9.embed-padd
				embed(src="#{movie.flash}",allowfullscreen="true",quality="high",align="middle",allowscriptaccess="always",type="application/x-shockwave-flash",title="Adobe Flash Player")
			.col-3
				div.asideTit.clearfix
					.col-6.tit01.titHover 影片简介
					.col-6.tit02 精彩推荐
				ul.dl-horizontal.introduce
					li
						i.fa.fa-angle-right
						| 电影名字: 
						span #{movie.title}
					li
						i.fa.fa-angle-right
						| 导演:
						span #{movie.doctor}
					li
						i.fa.fa-angle-right
						| 国家:
						span #{movie.country}
					li
						i.fa.fa-angle-right
						| 语言:
						span #{movie.language}
					li
						i.fa.fa-angle-right
						| 上映年份:
						span #{movie.year}
					li
						i.fa.fa-angle-right
						| 简介:
						p.detailSum #{movie.summary}
							script.
								$('.detailSum').text((cutstr($('.detailSum').text(),400)));
	.container.clearfix
		.comment.col-9
			h3.commentTit 
				|评论
				span.commentSum 
					span (
					span.commentCount #{comments.length}
					span )
				span.triangle
				span.triangle01
				span.line
			form
				input(type="hidden",name="movie",value="#{movie._id}")
				if user
					input(type="hidden",name="from",value="#{user._id}")
				.form-group.com-textarea
					textarea.form-control#com-textarea(name="content",row="6")
				.commentInfo.clearfix
					div.photoName.col-8
						img(src="http://0d077ef9e74d8.cdn.sohucs.com/fac494264beff70ed91fedf32783552b_default_1449555781335_jpg")
						span.username 137****9025_m2421
					.infoBtn.col-4
						if user
							button.btn.btn-success#publishComment(type="button") 发表评论
						else
							a(href="/admin/login").btn.btn-success 请先登录
			.comTit02
				span.comHot.spanActive 按热度
				span.comTime 按时间
			each comment in comments 
				div.commentItem.clearfix
					div.col-1.userPhoto
						img(src="/image/photo.jpg",alt="")
					div.col-11.commentMain
						p.title
							span.userName #{comment.from.username}
							span.publishTime #{moment(comment.meta.createAt).format('YYYY-MM-DD')}
						p.content #{comment.content}
						p.comicon
							i.fa.fa-thumbs-o-up
							i.fa.fa-thumbs-o-down
							span(onclick="showAnswer('"+comment._id+"')",id="show-"+comment._id) 回复
							span(onclick="hideAnswer('"+comment._id+"')",id="hide-"+comment._id,style="display:none;") 取消回复
							span 分享
						.div.answer(class="data-id-"+comment._id)
							form
								//当前主评论ID
								input(type="hidden",name="cid"+comment._id,value="#{comment._id}")
								//回复给谁
								input(type="hidden",name="tid"+comment._id,value="#{comment.from._id}")
								//当前评论者id
								if(user)
									input(type="hidden",name="from"+comment._id,value="#{user._id}")
								input.form-control(name=comment._id,placeholder="0/140字",id="reply-"+comment._id)
								button.btn.btn-success.answerBtn(type="button",id=comment._id) 回复评论
						div(id="answer-id-"+comment._id)
						if comment.reply && comment.reply.length > 0
							each reply in comment.reply
								div.commentItem.clearfix
									div.col-1.userPhoto
										img(src="/image/photo.jpg",alt="")
									div.col-11.commentMain
										p.title
											span.userName #{reply.from.username}
											span.publishTime #{moment(reply.createAt).format('YYYY年MM月DD日 hh:mm:ss')}
										p.content
											if reply.to.username != reply.from.username 
												span.aite 回复@#{reply.to.username}:
											span #{reply.content}
											p.comicon
												i.fa.fa-thumbs-o-up
												i.fa.fa-thumbs-o-down
												span(onclick="showAnswer('"+reply._id+"')",id="show-"+reply._id) 回复
												span(onclick="hideAnswer('"+reply._id+"')",id="hide-"+reply._id,style="display:none;") 取消回复
												span 分享
											.div.answer(class="data-id-"+reply._id)
												form
													//当前主评论ID
													input(type="hidden",name="cid"+reply._id,value="#{comment._id}")
													//回复给谁
													input(type="hidden",name="tid"+reply._id,value="#{reply.from._id}")
													//当前评论者id
													if(user)
														input(type="hidden",name="from"+reply._id,value="#{user._id}")
													input.form-control(name=reply._id,placeholder="0/140字",id="reply-"+reply._id)
													button.btn.btn-success.answerBtn(type="button",id=reply._id) 回复评论
	script(src="/libs/layer/layer.js")
	script(src="/js/detail.js")